package com.common.utils;

import java.io.InputStream;
import java.util.LinkedList;
import java.util.List;
import java.util.Properties;

/**
 * Created by Lenovo on 2015/7/21.
 */
public class
        HolidaysConfig {
    /*配置文件位置*/
    private final static String HOLIDAYS_CONFIG_FILE = "META-INF/common-config.properties";
    /*配置节假日的key*/
    private final static String HOLIDAYS_CONFIG = "holidays";

    private static Properties properties = new Properties();

    private static List<String> holidays = new LinkedList();

    /*类加载时加载*/
    static {
        try {
            InputStream is = HolidaysConfig.class.getClassLoader().getResourceAsStream(HOLIDAYS_CONFIG_FILE);
            properties.load(is);

            Object obj = properties.get(HOLIDAYS_CONFIG);
            if (obj != null){
                String str = obj.toString();
                String[] strs = str.split(",");
                for (String s : strs) {
                    holidays.add(s);
                }
            }
        }catch (Exception ex){
            throw new RuntimeException("load history config file error!", ex);
        }
    }

    /**返回配置中的节假日*/
    public static List<String> getHolidays(){
        return holidays;
    }
}
